package com.oppo.userServer.application.converter;

import com.oppo.userServer.infrastructure.dataObject.UserDO;
import com.oppo.userServer.presentationO.vo.UserResultVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 清梦
 * @version 1.0.0
 * @Description 数据转换层
 * @createTime 2024年03月11日 22:50:00
 */
public class UserDTOConverter {

    /**
     * 转换 用户do to result vo
     *
     * @param userDO 用户 DO
     * @return {@link List }<{@link UserResultVO }>
     * @author qingmeng
     * @createTime: 2024/03/11 23:10:18
     */
    public static List<UserResultVO> converterUserDOToResultVO(List<UserDO> userDO) {

        return userDO.stream().map(item -> {
            UserResultVO vo = new UserResultVO();
            vo.setId(item.getId());
            vo.setUserName(item.getUserName());
            vo.setUserPhone(item.getUserPhone());
            vo.setCreateTime(item.getCreateTime());
            vo.setUpdateTime(item.getUpdateTime());
            return vo;
        }).collect(Collectors.toList());
    }
}
